import service from "@/api/index.js";

const adminApi = {
    captcha() {
        return service.get("/admin/captcha")
    },
    login(username,password,key,captchaInput) {
        return service.post('/admin/login',{username, password, key, captchaInput},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
    getLoginInfo(){
        return service.get('/admin/info')
    },
//     修改个人密码
    updatePwd(oldPassword, newPassword, newPasswordAgain) {
        return service.put('/admin/updatePwd',{oldPassword, newPassword, newPasswordAgain}, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
//     修改个人信息
    updateOneInfo(admin) {
        return service.put('/admin/updateOneInfo',admin)
    },
//     获取全部管理员
    getAllByPage(pageNum, pageSize) {
        return service.get('/admin', {params: {pageNum,pageSize}})
    },
    getById(id) {
        return service.get(`/admin/${id}`)
    },
//    重置密码
    resetPwd(id) {
        return service.put(`/admin/resetPwd/${id}`)
    },
//     新增管理员
    addInfo(admin) {
        return service.post('/admin',admin)
    }
}

export default adminApi;